package com.haoxuewa.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.haoxuewa.dao.AdminDao;
import com.haoxuewa.dao.MessageDao;
import com.haoxuewa.entity.Message;
import com.haoxuewa.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class MessageServiceImpl extends ServiceImpl<MessageDao, Message> implements MessageService {

    private final MessageDao messageDao;

    @Autowired
    public MessageServiceImpl(MessageDao messageDao) {
        this.messageDao = messageDao;
    }


    @Override
    public List<Map<String, Object>> getAuditMessage() {
        return messageDao.selectMaps(new QueryWrapper<Message>().select("id", "text").last("limit " + 20));
    }

    @Override
    public Boolean messagePass(int id) {
        //insert into message(userName,text) select userName,text from message where id=#{id};
        //        delete from message where id=#{id}
//        return messageDao.removeMessageToUniform(id);
        return false;
    }

    @Override
    public Boolean messageUnPass(int id) {
        return messageDao.deleteById(id) == 1;
    }

}
